package com.ruoyi.xingcheng;

import org.apache.commons.codec.binary.Hex;

import java.util.ArrayList;
import java.util.List;

import static org.apache.commons.codec.digest.DigestUtils.sha1;

public class Test {
    public static void main(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();

        List<TelechatServiceApiContentParam> messages = new
                ArrayList<>();
        TelechatServiceApiContentParam
                telechatServiceApiContentParam = new
                TelechatServiceApiContentParam();
        telechatServiceApiContentParam.setContent("你是谁");
        messages.add(telechatServiceApiContentParam);
        for (TelechatServiceApiContentParam message : messages) {
            //内容
            stringBuilder.append(message.getContent()).append("-");
        }
        String secretKey = "E3533EFD8720ABADE6C99BC4FAD79D46";
        // 待加密内容
        String content = String.format("secretKey=%s&content=%s",
                secretKey, stringBuilder);
        // 签名
        String localSign = Hex.encodeHexString(sha1(content));
        System.out.println(localSign);
    }
}
